package com.example.view.module.scroll;

import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.common.base.AbsActivity;
import com.example.view.R;
import com.example.view.databinding.ActScrollImageBinding;

@Route(path = "/scroll/imageScroll")
public class ScrollImageActivity extends AbsActivity<ActScrollImageBinding> {
    @Override
    protected int getLayoutId() {
        return R.layout.act_scroll_image;
    }

    @Override
    protected void main() {

    }

    @Override
    protected void initListener() {
        mBinding.ivMain.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        System.out.println("ACTION_DOWN");
                        break;

                    case MotionEvent.ACTION_MOVE:
                        System.out.println("ACTION_MOVE");
                        break;

                    case MotionEvent.ACTION_UP:
                        System.out.println("ACTION_UP");
                        break;
                }
                return true;
            }
        });
    }

    public void scrollLeft(View v) {
        mBinding.ivMain.scrollBy(10, 0);
        Log.e("TAG", mBinding.ivMain.getScrollX() + "-");
    }

    public void scrollRight(View v) {
        mBinding.ivMain.scrollBy(-10, 0);
        Log.e("TAG", mBinding.ivMain.getScrollX() + "-");
    }

    public void scrollUp(View v) {
        mBinding.ivMain.scrollBy(0, 10);
        Log.e("TAG", mBinding.ivMain.getScrollX() + "-");
    }

    public void scrollDown(View v) {
        mBinding.ivMain.scrollBy(0, -10);
        Log.e("TAG", mBinding.ivMain.getScrollX() + "-");
    }

    public void reset1(View v) {
        mBinding.ivMain.scrollTo(0, 0);
    }

    public void reset2(View v) {
        mBinding.ivMain.reset();
    }
}
